
clear all
set more off

use "data/raw/defund-persuasion-deidentified", clear 

drop if !inlist(treatment, "article", "control")

keep if attention=="Extremely interested,Not at all interested"
drop attention

* Generate outcome and treatment variables
gen increase_funding = 2
replace increase_funding = 1 if defund == "Increased a little"
replace increase_funding = 0 if defund == "Stay about the same"
replace increase_funding = -1 if defund == "Decreased a little"
replace increase_funding = -2 if defund == "Decreased a lot"
label var increase_funding "How should police funding change?"

rename posterior post 
gen posterior = 2
replace posterior = 1 if post == "Somewhat increase violent crime"
replace posterior = 0 if post == "Neither increase nor decrease violent crime"
replace posterior = -1 if post == "Somewhat decrease violent crime"
replace posterior = -2 if post == "Strongly decrease violent crime"
drop post 
label var posterior "Posterior belief about effect of increasing funding"

gen info = treatment=="article"
lab var info "Information condition"
gen noinfo = treatment=="control"
lab var noinfo "Control condition"
drop treatment

* Generate demographic and control variables
gen ind = pol=="Independent"
lab var ind "Independent"
drop pol

gen partisan = .
replace partisan = 2 if liberal == "Very conservative"
replace partisan = 1 if liberal == "Conservative"
replace partisan = 0 if liberal == "Neither liberal nor conservative"
replace partisan = -1 if liberal == "Liberal"
replace partisan = -2 if liberal == "Very liberal"
label var partisan "Partisan leaning"

destring age, replace
label var age "Age"
gen age2 = age^2 
lab var age2 "Age squared"
gen hisp = hispanic=="Yes"
lab var hisp "Spanish, Hispanic, or Latino"
drop hispanic
rename male sex
gen male = sex == "Male"
lab var male "Male"
drop sex

lab var educ "Education level"
rename educ education

gen white = race=="Caucasian/White"
lab var white "White"
lab var race "Race"


keep info increase_funding posterior education race ind partisan age age2 hisp male white

save "data/working/defund-persuasion.dta", replace
exit,clear
